using System;
using NUnit.Framework;
using DotNetXmlSwfChart;

namespace DotNetXmlSwfChart.UnitTest
{
    [TestFixture]
    public class DrawLineFixture
    {
        [Test]
        public void DrawLineBackgroundLayerDissolveTransition()
        {
            LineTest(DrawLayer.background, TransitionType.dissolve);
        }

        [Test]
        public void DrawLineForegroundLayerDissolveTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.dissolve);
        }

        [Test]
        public void DrawLineBackgroundLayerDropTransition()
        {
            LineTest(DrawLayer.background, TransitionType.drop);
        }

        [Test]
        public void DrawLineForegroundLayerDropTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.drop);
        }

        [Test]
        public void DrawLineBackgroundLayerSpinTransition()
        {
            LineTest(DrawLayer.background, TransitionType.spin);
        }

        [Test]
        public void DrawLineForegroundLayerSpinTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.spin);
        }

        [Test]
        public void DrawLineBackgroundLayerScaleTransition()
        {
            LineTest(DrawLayer.background, TransitionType.scale);
        }

        [Test]
        public void DrawLineForegroundLayerScaleTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.scale);
        }

        [Test]
        public void DrawLineBackgroundLayerZoomTransition()
        {
            LineTest(DrawLayer.background, TransitionType.zoom);
        }

        [Test]
        public void DrawLineForegroundLayerZoomTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.zoom);
        }

        [Test]
        public void DrawLineBackgroundLayerBlinkTransition()
        {
            LineTest(DrawLayer.background, TransitionType.blink);
        }

        [Test]
        public void DrawLineForegroundLayerBlinkTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.blink);
        }

        [Test]
        public void DrawLineBackgroundLayerSlideRightTransition()
        {
            LineTest(DrawLayer.background, TransitionType.slide_right);
        }

        [Test]
        public void DrawLineForegroundLayerSlideRightTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.slide_right);
        }

        [Test]
        public void DrawLineBackgroundLayerSlideLeftTransition()
        {
            LineTest(DrawLayer.background, TransitionType.slide_left);
        }

        [Test]
        public void DrawLineForegroundLayerSlideLeftTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.slide_left);
        }

        [Test]
        public void DrawLineBackgroundLayerSlideUpTransition()
        {
            LineTest(DrawLayer.background, TransitionType.slide_up);
        }

        [Test]
        public void DrawLineForegroundLayerSlideUpTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.slide_up);
        }

        [Test]
        public void DrawLineBackgroundLayerSlideDownTransition()
        {
            LineTest(DrawLayer.background, TransitionType.slide_down);
        }

        [Test]
        public void DrawLineForegroundLayerSlideDownTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.slide_down);
        }

        [Test]
        public void DrawLineBackgroundLayerNoTransition()
        {
            LineTest(DrawLayer.background, TransitionType.none);
        }

        [Test]
        public void DrawLineForegroundLayerNoTransition()
        {
            LineTest(DrawLayer.foreground, TransitionType.none);
        }

        private void LineTest(DrawLayer layer, TransitionType type)
        {
            string testXml =
                "<line layer='{0}' " +
                      "transition='{1}' " +
                      "delay='1.2' " +
                      "duration='2.2' " +
                      "x1='20' " +
                      "y1='40' " +
                      "x2='30' " +
                      "y2='50' " +
                      "line_color='ffffff' " +
                      "line_alpha='1' " +
                      "line_thickness='2' " +
                      "/>";
            DrawLine line = new DrawLine();
            line.Layer = layer;
            line.Transition = type;
            line.Delay = 1.2;
            line.Duration = 2.2;
            line.X1 = 20;
            line.Y1 = 40;
            line.X2 = 30;
            line.Y2 = 50;
            line.LineColor = "ffffff";
            line.LineAlpha = 1;
            line.LineThickness = 2;
            Assert.AreEqual(
                string.Format(testXml, layer.ToString(), type.ToString()),
                line.ToSourceXML());
        }
    }
}
